package com.dc.service;


import com.dc.constant.Constants;
import com.dc.dao.UserDao;
import com.dc.entity.UserEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class UserService {

    @Resource
    private JwtTokenService tokenService;

    @Resource
    private UserDao userDao;

    public UserEntity getUser(HttpHeaders httpHeaders) {
        String token = httpHeaders.get(Constants.TAG_TOKEN).get(0);     // 不会为空
        String userName = tokenService.getUserNameFromToken(token);
        UserEntity user = userDao.findByUserName(userName);
        return user;
    }
}
